import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import  Counter from '../components/Counter'
import * as CounterActions from '../actions/counter'



//将state.counter 绑定到props的counter
function mapStateToProps(state) {
    return{
        counter: state.counter
    }
}

//将action的所有方法绑定到props上
function mapDispatchToProps(dispatch) {
    return bindActionCreators(CounterActions,dispatch)
}

//用connect方法将我们需要的state中的数据和actions中的方法绑定到props上，绑定后的组件是Counter
export default connect(mapStateToProps,mapDispatchToProps)(Counter)
